/* ======================================================= */
/**
 * File   : GraphicGroup.java
 * Date   : 2 mars 2010 at 23:32:38
 */
/* ======================================================= */
package fr.isima.isipaint.model;

import java.awt.Graphics2D;
import java.util.Collections;
import java.util.LinkedList;

/* ======================================================= */
/**
 * 
 * @author Daniel
 * 
 */
/* ======================================================= */
public class GraphicGroup extends GraphicObject {

	
	/** The list of GraphicObjects */
	private LinkedList<GraphicObject> group = new LinkedList<GraphicObject>();
	
	/**
	 * @return the group
	 */
	public final LinkedList<GraphicObject> getGroup() {
		return group;
	}

	public GraphicGroup()
	{
		super();
	}

	public boolean addGraphicObject(GraphicObject go) {
		boolean res;
		res = group.add(go);
		setChanged();
		notifyObservers();
		return res;
		
	}
	
	public boolean removeGraphicObject(GraphicObject go)
	{
		boolean res;
		res = group.remove(go);
		setChanged();
		notifyObservers();
		return res;
	}

	@Override
	public void draw(Graphics2D g) {

		Collections.sort(group);
		for (GraphicObject go : group) {
			go.draw(g);

		}
	}

}
